package com.thyme.system.controller;

import com.alibaba.fastjson.JSONObject;
import com.thyme.system.dao.WytDriverDao;
import com.thyme.system.dao.WytDriverEnterpriseDao;
import com.thyme.system.entity.SysUser;
import com.thyme.system.entity.WytDriverEnterprise;
import com.thyme.system.entity.WytDriverInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/driver")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class DriverController {
    private final WytDriverDao wytDriverDao;
    private final WytDriverEnterpriseDao enterpriseDao;

    @GetMapping("/user")
    public String index() {
        return "module/driver/user";
    }

    @GetMapping("/detail")
    public String detail(String id, Model model) {
        WytDriverInfo sysUser = wytDriverDao.getById(id);
        model.addAttribute("sysUser", JSONObject.toJSONString(sysUser));
        return "module/driver/detail";
    }

    @GetMapping("/enterprise")
    public String enterprise() {
        return "module/driver/enterprise";
    }

    @GetMapping("/enterprise/detail")
    public String enterpriseDetail(String id, Model model) {
        WytDriverEnterprise sysUser = enterpriseDao.getById(id);
        model.addAttribute("sysUser", JSONObject.toJSONString(sysUser));
        return "module/driver/enterpriseDetail";
    }
}
